/**
 * Framework for batch testing user profile models
 * Final project by Sergey Nepomnyachiy and Julia Polchin
 * Supervisor: Tsvi Kuflik
 *
 */
package core.generators.nested;

import interfaces.GeneratorInterface;

import java.util.Collection;
import java.util.Vector;

/**
 * Layer 2 generator - concats nested gen's data 
 * @author Sergey and Julia
 * 
 */
public class ConcatGenerator implements GeneratorInterface<Object> {
	/**
	 * nested generators
	 */
	private Collection<GeneratorInterface<?>> nested;
	private Vector<Object> vector = null;

	/**
	 * Constructor of the generator
	 * @param nested collection of nested generators
	 */
	public ConcatGenerator(Collection<GeneratorInterface<?>> nested) {
		this.nested = nested;
		this.vector = null;
	}

	@Override
	public Object getScalar() {
		return null;
	}

	@Override
	public Collection<Object> getVector() {
		if (null == this.vector) {
			this.vector = new Vector<Object>();

			for (GeneratorInterface<?> g : this.nested) {
				this.vector.addAll((g.getVector()));
			}
		}
		//System.out.println("Concat: " + this.vector);
		return this.vector;
	}

	@Override
	public boolean is2D() {
		return false;
	}

}
